home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 40
/
Aminet 40 (2000)(Schatztruhe)[!][Dec 2000].iso
/
Aminet
/
misc
/
emu
/
ATUtilities.lha
/
ATUtilities
/
M2
/
LISTS.MOD
< prev
next >
Wrap
Text File
|
2000-09-26
|
2KB
|
72 lines
IMPLEMENTATION MODULE Lists;
FROM SYSTEM IMPORT ADDRESS;
PROCEDURE AddHead(list : ListPtr; entry : NodePtr);
BEGIN
entry^.nextEntry := list^.firstEntry;
entry^.prevEntry := NIL;
entry^.list := list;
IF (list^.firstEntry # NIL) THEN
list^.firstEntry^.prevEntry := entry;
ELSE
list^.lastEntry := entry;
END (* IF *);
list^.firstEntry := entry;
END AddHead;
PROCEDURE AddTail(list : ListPtr; entry : NodePtr);
BEGIN
entry^.list := list;
IF (list^.lastEntry # NIL) THEN
list^.lastEntry^.nextEntry := entry;
entry^.prevEntry := list^.lastEntry;
entry^.nextEntry := NIL;
ELSE
list^.firstEntry := entry;
list^.lastEntry := entry;
entry^.prevEntry := NIL;
entry^.nextEntry := NIL;
END (* IF *);
END AddTail;
PROCEDURE NewList(list : ListPtr);
BEGIN
list^.firstEntry := NIL;
list^.lastEntry := NIL;
END NewList;
PROCEDURE Remove(entry : NodePtr);
BEGIN
IF (entry^.nextEntry # NIL) THEN
IF (entry^.prevEntry # NIL) THEN
entry^.prevEntry^.nextEntry := entry^.nextEntry;
entry^.nextEntry^.prevEntry := entry^.prevEntry;
ELSE
entry^.list^.firstEntry := entry^.nextEntry;
IF (entry^.list^.firstEntry^.nextEntry=NIL) THEN
entry^.list^.lastEntry := entry^.list^.firstEntry;
END (* IF *);
END (* IF *);
ELSE
IF (entry^.prevEntry # NIL) THEN
entry^.prevEntry^.nextEntry := NIL;
ELSE
entry^.list^.firstEntry := NIL;
entry^.list^.lastEntry := NIL;
END (* IF *);
END (* IF *);
END Remove;
PROCEDURE GetNext(node : NodePtr) : ADDRESS;
BEGIN
RETURN(node^.nextEntry);
END GetNext;
PROCEDURE GetPrev(node : NodePtr) : ADDRESS;
BEGIN
RETURN(node^.prevEntry);
END GetPrev;
END Lists.